//
//  UIView+frame.swift
//  Pods
//
//  Created by zhu xietong on 2017/8/14.
//
//

import Foundation

extension UIView {
    @IBInspectable var cornerRadius: CGFloat {
        get {
            return self.layer.cornerRadius
        }
        set {
            self.layer.cornerRadius = newValue
            self.layer.masksToBounds = newValue > 0
        }
    }
    
    @IBInspectable var borderWidth: CGFloat {
        get {
            return self.layer.borderWidth
        }
        set {
            self.layer.borderWidth = newValue
        }
    }
    
//    @IBInspectable var borderColor: UIColor {
//        get {
//            return UIColor(cgColor: self.layer.borderColor!)
//        }
//        set {
//            self.layer.borderColor = newValue.cgColor
//        }
//    }
}


extension UIView{
    
    public func fs_bottom(_ distance:CGFloat) ->CGFloat{
        return self.frame.origin.y + self.frame.size.height + distance
    }
    public func fs_top(_ distance:CGFloat) ->CGFloat{
        return self.frame.origin.y + distance
    }
    
    public func fs_left(_ distance:CGFloat) ->CGFloat{
        return self.frame.origin.x + distance
    }
    public func fs_right(_ distance:CGFloat) ->CGFloat {
        return self.frame.origin.x + self.frame.size.width + distance
    }
}


extension UIView
{
    @IBInspectable public var degree: Double {
        set(newValue) {
            let value = (newValue/180.0) * Double.pi
            self.transform = CGAffineTransform(rotationAngle: CGFloat(value))
        }
        get {
            return 0.0
        }
    }
    
}
